package com.zhiwang.planet.mvp.p

import com.zhiwang.planet.di.ActivityScope
import com.zhiwang.planet.mvp.v.WithDrawView
import com.zhiwang.planet.mvvm.model.RestApi
import com.zhiwang.planet.mvvm.model.request.WithDrawRequest
import com.zhiwang.planet.util.androidSchedule
import com.zhiwang.planet.util.responseFunc
import javax.inject.Inject

@ActivityScope
class WithDrawPresenter @Inject constructor(var restApi: RestApi) {

    lateinit var withdrawView: WithDrawView


    fun withdrawWx(cash: String, payPwd: String) {
        val withDrawRequest = WithDrawRequest(cash, payPwd)
        withDrawRequest.setTypeWx()
        val subscribe = restApi.withdraw(withDrawRequest)
                .androidSchedule()
                .responseFunc()
                .subscribe({
                    withdrawView.onWithDraw(it)
                }, {
                    withdrawView.onError(it)
                }, {

                })
    }


    fun withdrawAlipay(cash: String, payPwd: String) {
        val withDrawRequest = WithDrawRequest(cash, payPwd)
        withDrawRequest.setTypeAlipay()
        val subscribe = restApi.withdraw(withDrawRequest)
                .androidSchedule()
                .responseFunc()
                .subscribe({
                    withdrawView.onWithDraw(it)
                }, {
                    withdrawView.onError(it)
                }, {

                })
    }
}